// 模块：销售品设计/销售品基本信息
const OfferBase = {
    delimiters: ['${', '}'],
    data() {
        return {
            offer_name: ''
        }
    },
    computed: {
        offer_sys_name: function () {
            let s = ''
            if (this.offer_name > '') {
                let now = new Date()
                let yyyy = now.getFullYear()
                let mm = now.getMonth() + 1 < 10 ? "0" + (now.getMonth() + 1) : now.getMonth() + 1;
                s = yyyy + mm + '-' + this.offer_name
            }
            return s
        }
    },
    methods: {
        check_homonym: function () {
            axios
                .get('api/v1/qry-offer/' + this.offer_name)
                .then(function (response) {
                    if (response.data.code == 200) {
                        let result = response.data.result
                        let msg = ''
                        for (let i = 0; i < result.length; i++) {
                            msg += '[' + result[i].status_cd + ']' + result[i].offer_id + ':' + result[i].offer_name + '\n'
                        }
                        if (msg > '') {
                            alert('发现同名销售品：\n' + msg);
                        }
                    } else {
                        alert('销售品重名识别失败!')
                    }
                })
                .catch(function (error) {
                    console.log(error);
                })
        }
    }
}
Vue.createApp(OfferBase).mount('#collapse-offer-base')